package com.eedi.framework.config.controller.sys;

import com.eedi.framework.config.controller.sys.vo.paymerchant.PayMerchantCfgReq;
import com.eedi.framework.config.service.HospitalConfigService;
import com.eedi.framework.common.pojo.CommonResult;
import com.eedi.framework.config.controller.sys.vo.paymerchant.PayMerchantCfgResp;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import static com.eedi.framework.common.pojo.CommonResult.success;


/**
 * @author zybourn
 * @version 1.0
 * @description
 * @since 2024/3/13 19:22
 **/

//@Tag(name = "系统界面 - 支付商户配置管理")
//@RestController
//@RequestMapping("/pay-merchant-cfg")
//@Validated
public class PayMerchantConfigController {

    @Resource
    private HospitalConfigService hospitalConfigService;
    /**
     * 保存支付商户号配置
     * @param payMerchantCfgReq 支付商户号信息
     * @return
     */
    @PostMapping("/save")
    public CommonResult<Boolean> savePayMerchantConfig(@RequestBody @Validated PayMerchantCfgReq payMerchantCfgReq) {
        hospitalConfigService.addOrUpdatePayMerchantConfig(payMerchantCfgReq);
        return success(true);
    }

    /**
     *
     * 删除支付商户号配置
     * @param payMerchantType 支付商户号类型
     * @return
     */
    @GetMapping("/del")
    @Parameter(name = "payMerchantType", description = "支付商户类型", required = true)
    public CommonResult<Boolean> delPayMerchantConfig(Integer payMerchantType) {
        hospitalConfigService.delPayMerchantConfig(payMerchantType);
        return success(true);
    }

    /**
     * 查询所有支付商户号配置
     * @return
     */
    @GetMapping("/list")
    public CommonResult<List<PayMerchantCfgResp>> listPayMerchantConfig() {
        return success(hospitalConfigService.getPayMerchantConfig());
    }
}
